I said today I want to do a little bit of code cleanup.
I got two things that I want to change.
One, if we get a brand new player, they get a message that they blew their daily streak.
So we want to say something like welcome or whatever.
And then two, the game manager is loading the character added event for some people a little bit too
slow and then they don't get credit for their kills and deaths until they die at least once and then
they get re added to the game.
So let's change those.
Let's make them a little better.
We'll go to game manager if you don't know where it's at.
Server script service, game manager and let's start on our our welcome screen.
Well, not a welcome screen.
We'll just do the welcome message.
Maybe we'll do a screen later.
So check daily streaks.
That's fine.
Initialize player.
That's what we want.
So what I'm going to do here is uncomment out this data store, set a sync.
This is going to clear all my data so I can check it.
Unfortunately, I'm going to lose all my data.
I'm going to lose my pistol, my money, everything else.
But that's all right.
We've got to check this out.
So that's going to clear our data here if somebody has data.
They had already played.
So we populate their leaderboard and the player info stuff on the player.
If they have not played and they don't have data.
We go ahead and initialize this table, but we set the streak to zero.
Let's make that one.
And we set the time to January 1st, 1970 at midnight, which is Epoch.
We don't want that.
Let's make it OSS time.
All right.
Now we're still going to get the error.
We're not going to get the error.
We're still going to get you blew your streak message.
So we have to update the player info.
Luckily, right here is exactly what we've got to do.
I guess we could refactor it further so that we don't have to duplicate lines of code, but it's fine.
All right.
So then we're going to get our data, we're going to update our saved time and streak value in our player
info.
And then let's send a message to the screen using our queue service saying new player or welcome new
player.
So I'm going to scroll up.
I'm just going to copy it somewhere else.
Here it is.
Am I my daily streak check.
Daily streak code for you blew your streak.
That's a good one.
Let's go back down here.
Paste it.
And I'll just say, Welcome, new player.
All right.
Now, when we go ahead and play this, we're going to be a new player because I'm clearing out my data.
Let's give it a shot.
We should get our welcome new player to.
Boom.
Welcome, new player.
All right, cool.
Now we just have to make sure that our kills and death leaderboard is firing on time.
Let's do that.
All right.
I am back in my game manager.
Don't forget to comment out your set a sink so you don't clear your data every time you play the game.
And then let's scroll on down to player added.
All right, So Player added.
If this character added gets connected with the player character at an event is connected after the
player is already in the world, it won't be effective until they die and come back into the world.
So what we've got to do.
Is this stuff is slowing us down.
This in particular, this initialized player data that's slow.
Let's just go ahead and and do a cut.
And now we'll just plop it right on down here.
Boom!
All right.
And this stuff here should be fine without any data.
It's just going to go right on through.
And we check again.
We do the initialize.
We check again.
I think we're good.
Let's give it a shot.
Hit play.
And we should be playing the same day.
So no big deal.
Let's kill ourselves.
Deaths.
One.
Good.
I'm going to play a little bit to make sure that we're saving our data and then get a gun, and then
we'll see how that goes.
All right.
So I played a little bit.
I got a pistol.
I actually gave myself an extra 1000 points.
But let's see if we got it.
So if there's any errors, pistols here.
That's looking good.
We have our points and we have our kills.
We have our deaths.
Let me go ahead and step on a landmine real quick just to make sure it's doing doing okay.
Yeah.
There we go.
We're up and running.